package com.huanbao.nongwu.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huanbao.nongwu.dao.AdminAreaDao;
import com.huanbao.nongwu.dao.AreaDao;
import com.huanbao.nongwu.pojo.AreaVO;
import com.huanbao.nongwu.pojo.SysUserVO;
import com.huanbao.nongwu.pojo.beans.AdminArea;
import com.huanbao.nongwu.pojo.beans.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/* ━━━━━━佛祖保佑━━━━━━
 *                  ,;,,;
 *                ,;;'(    社
 *      __      ,;;' ' \   会
 *   /'  '\'~~'~' \ /'\.)  主
 * ,;(      )    /  |.     义
 *,;' \    /-.,,(   ) \    码
 *     ) /       ) / )|    农
 *     ||        ||  \)
 *     (_\       (_\
 * ━━━━━━永无BUG━━━━━━
 * @author ：zjq
 * @date ：2021/3/24 15:31
 * @description: TODO
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 */
@Service
public class AreaServiceImpl {

    @Autowired
    private AreaDao areaDao;

    @Autowired
    private AdminAreaDao adminAreaDao;


    public PageInfo<SysUserVO> getAreasByPaging(Map<String, Object> map) {
        int pageNum = (int) map.get("pageNum");
        int pageSize = (int) map.get("pageSize");

        PageHelper.startPage(pageNum, pageSize);
        List<AreaVO> areaList = areaDao.getAreaVOByPaging();
        PageInfo<SysUserVO> pageInfo = new PageInfo(areaList);
        return pageInfo;
    }


    public int insertSelective(Area record) {
        return areaDao.insert(record);
    }

    public int insert(AdminArea record) {
        int count = adminAreaDao.insert(record);
        return count;
    }

    public int deleteByPrimaryKey(Integer id) {
        int count = areaDao.deleteById(id);
        return count;
    }

    public int deleteAdminAreaByAreaId(Integer areaid) {
        return adminAreaDao.deleteAdminAreaByAreaid(areaid);
    }

    public Area selectByPrimaryKey(Integer id){
        Area area = areaDao.selectById(id);
        return area;
    }

}
